//
//  MainViewController.swift
//  WBObject512
//
//  Created by pro on 2018/6/29.
//  Copyright © 2018年 ChenXiaoJun. All rights reserved.
//

import UIKit

class MainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        addChildViewController(childVC: HomeViewController(), title: "主页", icon: "tabbar_home")
        addChildViewController(childVC: DiscoverViewController(), title: "发现", icon: "tabbar_discover")
        addChildViewController(childVC: MessageViewController(), title: "消息", icon: "tabbar_message_center")
        addChildViewController(childVC: ProfileViewController(), title: "我的", icon: "tabbar_profile")

    }
    
    //添加子控制器
    func addChildViewController(childVC: UIViewController,title:String,icon:String) {
        let navVC = UINavigationController(rootViewController: childVC)
        childVC.title = title
        navVC.tabBarItem.title = title
        navVC.tabBarItem.image = UIImage(named: icon)
        navVC.tabBarItem.selectedImage = UIImage(named: icon + "_highlighted")
        addChildViewController(navVC)
    }
}
